<%@ page language="java"
         contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ page isELIgnored="false" %>
<!-- isELIgnored=true禁用EL表达式 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!-- JSTL格式化标签 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/index.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/indexstyle.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
</head>
<body id="list-cont class= layui-bg-black">
<div style="width: 100%; margin: 0 auto;">
    <input type="password" class="layui-input" placeholder="请输入支付密码" id="pass">
    <br>
    <button class="layui-btn layui-btn-warm layui-btn-fluid" onclick="pay('${orderNo}')">支付</button>
</div>
</body>
<script>
    function pay(orderNo){
        var pass = $("#pass").val();
        if (pass == null || pass == ''){
            alert("密码不能为空！")
            return;
        }
        var params = "uPass=" + pass + "&orderNo=" + orderNo
        console.info(params);

        //提交密码，扣款
        $.ajax({
           url:"${pageContext.request.contextPath}/shop/goods/pay",
           data:params,
            type:"post",
            success:function (date){
                var j = JSON.parse(date);
                // 支付成功
                if (j.code == 1) {
                    alert(j.msg)
                    window.parent.open("${pageContext.request.contextPath}/shop/goods/orderPage","_self");
                }else {// 支付失败
                    alert(j.msg)
                    window.parent.location.reload();
                }
            }
        });
    }
</script>
</html>
